<?
require_once("$_SERVER[ROOT_PATH]/inc/init.php");
$act = $_REQUEST["act"];

//时间
if($act=="getdate"){
	//echo date("Y-m-d");
	echo file_get_contents("http://likaituan.net/test/gettime.php");
}

//获取淘宝数据
elseif($act=="gettaobao"){
	$tb = "shop_taobao";
	$page = $_GET["page"];
	$size = $_GET["size"];
	$limit = "limit ".($page-1)*$size.",$size";
	$a = array(
		"num" => $db->getOne("select count(id) from $tb"),
		"data" => $db->getAll("select * from $tb $limit"),
	);
	echo json_encode($a);
}

//获取省市县
elseif($act=="region"){
	echo json_encode($db->getAll("select * from region where region_type>0 and region_type<3"));
}

//表单验证
elseif($act=="form"){
	$chk = $_GET["chk"];
	$val = isset($_GET["val"]) ? $_GET["val"] : "";
	
	//检查表单
	if($chk=="form"){
		echo "提交成功！\n";
		print_r($_GET);
	}
	
	//检查用户名
	elseif($chk=="username"){
		echo ($val=="li"||$val=="admin") ? 2 : 1;
	}	
}

//读取本地文件
elseif($act=="readFile"){
	$fileName = $_GET["fileName"];
	$funName = $_GET["funName"];
	print_r($_FILES);exit();
	echo $funName.'(\'parent.'.file_get_contents($_FILES[$fileName]['tmp_name']).'\')';
}
?>